import React from 'react'
import { Popconfirm, message } from 'antd'
import { useTranslation } from 'react-i18next'

const Pop = (props: any) => {
  const { t } = useTranslation()
  const { onConfirm } = props
  const children = React.Children.toArray(props?.children)
  return (
    <Popconfirm
      title={t('pop.title')}
      description={t('pop.desc')}
      onConfirm={onConfirm}
      onCancel={() => {
        message.info(t('pop.cancel'))
      }}
      okText={t('pop.yes')}
      cancelText={t('pop.no')}
    >
      {children.map((item: any, index: number) => {
        return <React.Fragment key={index}>{item}</React.Fragment>
      })}
    </Popconfirm>
  )
}

export default Pop
